VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "LCompania"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit

Dim dao As DAOCompania
Dim logDAO As DAOLog
Dim daoPuntoVenta As daoPuntoVenta
Private Const MODULO As String = "COMPANIA"
'---------------------------------------------------------------------------------------
' Procedure : Class_Initialize
' DateTime  : 17/03/2008 23:48
' Author    : FRANCO
' Purpose   : Inicializa los objetos de la clase
'---------------------------------------------------------------------------------------
'
Private Sub Class_Initialize()
Set dao = New DAOCompania
Set logDAO = New DAOLog
Set daoPuntoVenta = New daoPuntoVenta
End Sub


'---------------------------------------------------------------------------------------
' Procedure : getLista
' DateTime  : 20/04/2008 23:47
' Author    : FRANCO
' Purpose   : Obtiene una lista de objetos
'---------------------------------------------------------------------------------------
'
Public Function getLista(rutaInis As String) As Collection
Dim result As Collection
Dim bean As New bCompania
bean.bEstado.nCodigo = UtilConstantes.ESTADO_COMPANIA_ACTIVA
Set dao.Connection = utilConexion
Set result = dao.getLista(bean)
Set daoPuntoVenta.Connection = utilConexion
If Not result Is Nothing Then
    Set getLista = result
    Dim i As Integer
    Dim UtilArchivoIni As New UtilArchivoIni
    Dim bCompania As bCompania
    For i = 1 To result.Count
        Set bCompania = result.Item(i)
        Set bCompania.bPuntoVenta = UtilArchivoIni.obtenerPOS(rutaInis + "\" + bCompania.sRuc + ".ini", bCompania)
        If Trim(bCompania.bPuntoVenta.sSerie) = "" Then
                utilMensaje.muestraMensaje CargaIncompletaPuntoVenta, bCompania.sRazonSocial
                End
        Else
            If bCompania.bPuntoVenta Is Nothing Then
                utilMensaje.muestraMensaje CargaIncompletaPuntoVenta, bCompania.sRazonSocial
                End
            End If
        End If
        Set bCompania.bPuntoVenta = daoPuntoVenta.getBean(bCompania)
    Next
    
    
Else
    capturarError UtilConstantes.STR_LISTAR
    error = UtilConstantes.OPT_ERROR_ENCONTRADO
End If

hnderr:
If Err.Number = 0 Then Exit Function
capturarError UtilConstantes.STR_LISTAR
End Function


Public Function getListaTodas() As Collection
Dim bean As New bCompania
bean.bEstado.nCodigo = UtilConstantes.ESTADO_COMPANIA_ACTIVA
Set dao.Connection = utilConexion
Set getListaTodas = dao.getLista(bean)
hnderr:
If Err.Number = 0 Then Exit Function
utilMensaje.muestraMensaje errorEncontrado, Err.Description
End Function

Private Sub capturarError(opcion As String)
Set bLog.bUsuario = bparametro.bUsuarioActivo
bLog.sOpcion = opcion
bLog.sModulo = MODULO
If bConfiguracion.guardarHistorialSucesos Then
    Set logDAO.Connection = utilConexion
    logDAO.guardarNuevo bLog
End If
If bConfiguracion.enviarMailSuceso Then
    'TO DO
End If
Set bLog = Nothing
End Sub

